#include <iostream>
#include <vector>

using namespace std;

int main()
{
    int n, a, b;
    cin >> n;
    vector<int> arr(n);
    vector<int> sum(n);
    for(int i = 0; i < n; i++)
    {
        cin >> arr[i];
        if(i == 0)
        {
            sum[i] = arr[i];
        }
        else
        {
            sum[i] = sum[i - 1] + arr[i];
        }
    }
    while (cin >> a >> b)
    {
        if(a == 0)
        {
            cout << sum[b] << endl;
        }
        else
        {
            cout << (sum[b] - sum[a -1]) << endl;
        }
    } 
}